{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "np.random.seed(8)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from keras.models import Sequential\n",
    "from keras.layers import Dense"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['satisfaction_level', 'last_evaluation', 'number_project',\n",
       "       'average_montly_hours', 'time_spend_company', 'Work_accident',\n",
       "       'promotion_last_5years', 'salary_high', 'salary_low', 'salary_medium',\n",
       "       'sales_IT', 'sales_RandD', 'sales_accounting', 'sales_hr',\n",
       "       'sales_management', 'sales_marketing', 'sales_product_mng',\n",
       "       'sales_sales', 'sales_support', 'sales_technical'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# load hrdataset\n",
    "hr_data = pd.read_csv('data/hr.csv', header=0)\n",
    "# split into input (X) and output (Y) variables\n",
    "data_trnsf = pd.get_dummies(hr_data, columns =['salary', 'sales'])\n",
    "data_trnsf.columns\n",
    "X = data_trnsf.drop('left', axis=1)\n",
    "X.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "       satisfaction_level  last_evaluation  number_project  \\\n",
      "12602                0.10             0.84               7   \n",
      "4889                 0.57             0.68               4   \n",
      "1572                 0.39             0.48               2   \n",
      "13375                0.91             0.68               4   \n",
      "879                  0.82             0.97               5   \n",
      "1578                 0.10             0.96               6   \n",
      "8765                 0.92             0.51               4   \n",
      "1509                 0.44             0.52               2   \n",
      "1896                 0.39             0.49               2   \n",
      "4520                 0.70             0.44               2   \n",
      "4112                 0.88             0.98               3   \n",
      "11675                0.17             0.61               6   \n",
      "1845                 0.43             0.56               2   \n",
      "4914                 0.74             0.53               5   \n",
      "14738                0.09             0.90               7   \n",
      "9281                 0.32             0.64               3   \n",
      "9500                 0.91             0.94               4   \n",
      "6311                 0.80             0.88               5   \n",
      "7496                 0.57             0.39               2   \n",
      "13895                0.69             0.85               3   \n",
      "13132                0.55             0.98               4   \n",
      "9526                 0.45             0.87               2   \n",
      "14114                0.96             0.62               4   \n",
      "5403                 0.68             0.81               3   \n",
      "5821                 0.72             0.84               3   \n",
      "3614                 0.91             0.68               3   \n",
      "2108                 0.74             0.76               5   \n",
      "13496                0.64             0.67               3   \n",
      "9440                 0.57             0.49               2   \n",
      "14946                0.10             0.84               5   \n",
      "...                   ...              ...             ...   \n",
      "3385                 0.79             0.55               3   \n",
      "4555                 1.00             0.59               3   \n",
      "1184                 0.46             0.45               2   \n",
      "6420                 0.68             0.54               3   \n",
      "5051                 0.62             0.52               3   \n",
      "5311                 0.86             0.75               5   \n",
      "2433                 0.87             0.84               5   \n",
      "6949                 0.87             0.57               3   \n",
      "13803                0.95             0.84               3   \n",
      "10583                0.91             0.88               3   \n",
      "769                  0.42             0.46               2   \n",
      "1685                 0.76             0.98               5   \n",
      "8322                 0.55             0.75               4   \n",
      "11111                0.94             0.73               4   \n",
      "11363                0.57             0.60               2   \n",
      "11636                0.41             0.67               6   \n",
      "14423                0.88             1.00               5   \n",
      "5578                 0.47             0.55               2   \n",
      "4426                 0.88             0.66               4   \n",
      "13526                0.66             0.77               4   \n",
      "466                  0.37             0.48               2   \n",
      "6265                 0.99             0.55               4   \n",
      "5734                 0.53             0.54               4   \n",
      "11284                0.90             0.51               4   \n",
      "11964                0.82             0.80               5   \n",
      "5191                 0.52             0.96               4   \n",
      "13418                0.49             0.65               4   \n",
      "5390                 0.66             0.73               5   \n",
      "860                  0.79             1.00               4   \n",
      "7270                 0.98             0.86               2   \n",
      "\n",
      "       average_montly_hours  time_spend_company  Work_accident  \\\n",
      "12602                   250                   4              0   \n",
      "4889                    154                   3              1   \n",
      "1572                    154                   3              0   \n",
      "13375                   132                   4              0   \n",
      "879                     263                   5              0   \n",
      "1578                    310                   5              0   \n",
      "8765                    167                   3              1   \n",
      "1509                    128                   3              0   \n",
      "1896                    127                   3              0   \n",
      "4520                    131                   2              0   \n",
      "4112                    160                   2              0   \n",
      "11675                   154                  10              1   \n",
      "1845                    129                   3              0   \n",
      "4914                    141                   2              0   \n",
      "14738                   289                   4              0   \n",
      "9281                    151                   3              0   \n",
      "9500                    264                   4              0   \n",
      "6311                    199                   4              0   \n",
      "7496                    145                   3              0   \n",
      "13895                   153                  10              0   \n",
      "13132                   185                   2              1   \n",
      "9526                    268                   4              1   \n",
      "14114                   253                   7              0   \n",
      "5403                    166                   2              0   \n",
      "5821                    167                   3              0   \n",
      "3614                    218                   3              1   \n",
      "2108                    104                   4              0   \n",
      "13496                   143                   6              0   \n",
      "9440                    237                   2              0   \n",
      "14946                   303                   5              0   \n",
      "...                     ...                 ...            ...   \n",
      "3385                    147                   3              0   \n",
      "4555                    168                   3              0   \n",
      "1184                    143                   3              0   \n",
      "6420                    270                   4              1   \n",
      "5051                    148                   3              0   \n",
      "5311                    157                   4              0   \n",
      "2433                    137                   2              0   \n",
      "6949                    149                   2              0   \n",
      "13803                   240                   7              0   \n",
      "10583                   189                   2              0   \n",
      "769                     141                   3              0   \n",
      "1685                    242                   5              0   \n",
      "8322                    166                   2              0   \n",
      "11111                   204                   2              0   \n",
      "11363                   163                   3              0   \n",
      "11636                   221                  10              0   \n",
      "14423                   219                   5              0   \n",
      "5578                    156                   2              0   \n",
      "4426                    133                   2              0   \n",
      "13526                   188                   2              0   \n",
      "466                     134                   3              0   \n",
      "6265                    179                   4              0   \n",
      "5734                    257                   3              1   \n",
      "11284                   137                   6              0   \n",
      "11964                   205                   3              0   \n",
      "5191                    246                   3              0   \n",
      "13418                   233                   7              0   \n",
      "5390                    249                   2              0   \n",
      "860                     218                   5              0   \n",
      "7270                    219                   4              0   \n",
      "\n",
      "       promotion_last_5years  salary_high  salary_low  salary_medium  \\\n",
      "12602                      0            0           1              0   \n",
      "4889                       0            0           0              1   \n",
      "1572                       0            0           1              0   \n",
      "13375                      0            0           0              1   \n",
      "879                        0            0           0              1   \n",
      "1578                       0            0           1              0   \n",
      "8765                       0            0           0              1   \n",
      "1509                       0            0           0              1   \n",
      "1896                       0            0           0              1   \n",
      "4520                       0            0           1              0   \n",
      "4112                       0            0           0              1   \n",
      "11675                      0            0           0              1   \n",
      "1845                       0            0           1              0   \n",
      "4914                       0            0           1              0   \n",
      "14738                      0            0           1              0   \n",
      "9281                       0            0           1              0   \n",
      "9500                       0            0           1              0   \n",
      "6311                       0            0           1              0   \n",
      "7496                       0            0           0              1   \n",
      "13895                      0            0           0              1   \n",
      "13132                      0            0           1              0   \n",
      "9526                       0            0           1              0   \n",
      "14114                      0            0           0              1   \n",
      "5403                       0            0           0              1   \n",
      "5821                       0            0           0              1   \n",
      "3614                       0            0           0              1   \n",
      "2108                       0            0           1              0   \n",
      "13496                      0            0           0              1   \n",
      "9440                       0            0           1              0   \n",
      "14946                      0            0           0              1   \n",
      "...                      ...          ...         ...            ...   \n",
      "3385                       0            0           0              1   \n",
      "4555                       1            0           1              0   \n",
      "1184                       0            0           1              0   \n",
      "6420                       0            0           1              0   \n",
      "5051                       0            0           0              1   \n",
      "5311                       0            0           1              0   \n",
      "2433                       0            0           1              0   \n",
      "6949                       0            0           0              1   \n",
      "13803                      0            0           0              1   \n",
      "10583                      0            0           0              1   \n",
      "769                        0            0           0              1   \n",
      "1685                       0            0           1              0   \n",
      "8322                       0            0           1              0   \n",
      "11111                      0            0           1              0   \n",
      "11363                      0            0           0              1   \n",
      "11636                      0            0           0              1   \n",
      "14423                      0            0           1              0   \n",
      "5578                       0            0           0              1   \n",
      "4426                       0            0           0              1   \n",
      "13526                      0            0           1              0   \n",
      "466                        0            0           0              1   \n",
      "6265                       0            0           1              0   \n",
      "5734                       0            0           1              0   \n",
      "11284                      0            0           0              1   \n",
      "11964                      0            0           1              0   \n",
      "5191                       0            0           1              0   \n",
      "13418                      0            0           0              1   \n",
      "5390                       0            0           0              1   \n",
      "860                        0            0           1              0   \n",
      "7270                       0            0           1              0   \n",
      "\n",
      "       sales_IT  sales_RandD  sales_accounting  sales_hr  sales_management  \\\n",
      "12602         0            0                 0         0                 0   \n",
      "4889          0            0                 0         0                 1   \n",
      "1572          0            0                 0         0                 0   \n",
      "13375         1            0                 0         0                 0   \n",
      "879           0            0                 0         0                 0   \n",
      "1578          0            0                 0         0                 0   \n",
      "8765          1            0                 0         0                 0   \n",
      "1509          0            0                 0         0                 0   \n",
      "1896          1            0                 0         0                 0   \n",
      "4520          0            0                 0         0                 0   \n",
      "4112          0            0                 0         0                 0   \n",
      "11675         0            0                 0         0                 0   \n",
      "1845          0            0                 0         0                 0   \n",
      "4914          0            0                 1         0                 0   \n",
      "14738         0            0                 0         0                 0   \n",
      "9281          0            0                 0         0                 0   \n",
      "9500          0            0                 0         0                 0   \n",
      "6311          0            0                 0         0                 0   \n",
      "7496          0            0                 0         0                 0   \n",
      "13895         0            0                 0         0                 0   \n",
      "13132         0            0                 0         0                 0   \n",
      "9526          1            0                 0         0                 0   \n",
      "14114         0            0                 0         0                 0   \n",
      "5403          1            0                 0         0                 0   \n",
      "5821          0            0                 0         0                 0   \n",
      "3614          0            0                 1         0                 0   \n",
      "2108          0            0                 0         0                 0   \n",
      "13496         0            0                 0         0                 0   \n",
      "9440          0            0                 0         0                 0   \n",
      "14946         0            0                 1         0                 0   \n",
      "...         ...          ...               ...       ...               ...   \n",
      "3385          0            0                 0         0                 0   \n",
      "4555          0            0                 0         0                 0   \n",
      "1184          0            0                 0         0                 0   \n",
      "6420          0            0                 0         0                 0   \n",
      "5051          0            0                 0         0                 0   \n",
      "5311          0            0                 0         0                 0   \n",
      "2433          0            0                 0         0                 0   \n",
      "6949          0            0                 1         0                 0   \n",
      "13803         0            0                 0         0                 0   \n",
      "10583         0            0                 0         0                 0   \n",
      "769           0            0                 0         0                 0   \n",
      "1685          0            0                 0         0                 1   \n",
      "8322          0            0                 0         0                 0   \n",
      "11111         0            0                 0         0                 0   \n",
      "11363         0            0                 0         0                 0   \n",
      "11636         0            0                 0         0                 0   \n",
      "14423         0            0                 0         0                 0   \n",
      "5578          0            0                 0         0                 1   \n",
      "4426          0            1                 0         0                 0   \n",
      "13526         0            0                 0         0                 0   \n",
      "466           0            0                 0         0                 0   \n",
      "6265          0            0                 0         0                 0   \n",
      "5734          0            0                 0         0                 0   \n",
      "11284         0            0                 0         0                 0   \n",
      "11964         1            0                 0         0                 0   \n",
      "5191          0            0                 0         0                 0   \n",
      "13418         0            0                 0         0                 0   \n",
      "5390          0            0                 0         0                 0   \n",
      "860           0            0                 0         0                 0   \n",
      "7270          0            0                 0         0                 0   \n",
      "\n",
      "       sales_marketing  sales_product_mng  sales_sales  sales_support  \\\n",
      "12602                0                  1            0              0   \n",
      "4889                 0                  0            0              0   \n",
      "1572                 0                  0            0              0   \n",
      "13375                0                  0            0              0   \n",
      "879                  0                  0            0              0   \n",
      "1578                 0                  0            0              1   \n",
      "8765                 0                  0            0              0   \n",
      "1509                 0                  0            0              0   \n",
      "1896                 0                  0            0              0   \n",
      "4520                 0                  0            1              0   \n",
      "4112                 0                  1            0              0   \n",
      "11675                0                  0            1              0   \n",
      "1845                 0                  0            1              0   \n",
      "4914                 0                  0            0              0   \n",
      "14738                0                  1            0              0   \n",
      "9281                 0                  0            0              1   \n",
      "9500                 0                  0            0              0   \n",
      "6311                 0                  0            0              1   \n",
      "7496                 0                  0            1              0   \n",
      "13895                0                  0            0              1   \n",
      "13132                1                  0            0              0   \n",
      "9526                 0                  0            0              0   \n",
      "14114                0                  0            1              0   \n",
      "5403                 0                  0            0              0   \n",
      "5821                 0                  0            1              0   \n",
      "3614                 0                  0            0              0   \n",
      "2108                 0                  0            0              1   \n",
      "13496                0                  0            1              0   \n",
      "9440                 0                  0            0              1   \n",
      "14946                0                  0            0              0   \n",
      "...                ...                ...          ...            ...   \n",
      "3385                 0                  0            1              0   \n",
      "4555                 0                  0            0              1   \n",
      "1184                 0                  0            0              0   \n",
      "6420                 0                  0            1              0   \n",
      "5051                 0                  0            1              0   \n",
      "5311                 0                  0            0              1   \n",
      "2433                 0                  1            0              0   \n",
      "6949                 0                  0            0              0   \n",
      "13803                0                  0            1              0   \n",
      "10583                0                  0            0              1   \n",
      "769                  1                  0            0              0   \n",
      "1685                 0                  0            0              0   \n",
      "8322                 0                  0            1              0   \n",
      "11111                0                  0            1              0   \n",
      "11363                0                  0            1              0   \n",
      "11636                1                  0            0              0   \n",
      "14423                0                  0            0              0   \n",
      "5578                 0                  0            0              0   \n",
      "4426                 0                  0            0              0   \n",
      "13526                0                  0            0              0   \n",
      "466                  1                  0            0              0   \n",
      "6265                 1                  0            0              0   \n",
      "5734                 1                  0            0              0   \n",
      "11284                0                  0            1              0   \n",
      "11964                0                  0            0              0   \n",
      "5191                 0                  0            0              1   \n",
      "13418                0                  0            1              0   \n",
      "5390                 0                  0            0              1   \n",
      "860                  0                  0            1              0   \n",
      "7270                 0                  0            1              0   \n",
      "\n",
      "       sales_technical  \n",
      "12602                0  \n",
      "4889                 0  \n",
      "1572                 1  \n",
      "13375                0  \n",
      "879                  1  \n",
      "1578                 0  \n",
      "8765                 0  \n",
      "1509                 1  \n",
      "1896                 0  \n",
      "4520                 0  \n",
      "4112                 0  \n",
      "11675                0  \n",
      "1845                 0  \n",
      "4914                 0  \n",
      "14738                0  \n",
      "9281                 0  \n",
      "9500                 1  \n",
      "6311                 0  \n",
      "7496                 0  \n",
      "13895                0  \n",
      "13132                0  \n",
      "9526                 0  \n",
      "14114                0  \n",
      "5403                 0  \n",
      "5821                 0  \n",
      "3614                 0  \n",
      "2108                 0  \n",
      "13496                0  \n",
      "9440                 0  \n",
      "14946                0  \n",
      "...                ...  \n",
      "3385                 0  \n",
      "4555                 0  \n",
      "1184                 1  \n",
      "6420                 0  \n",
      "5051                 0  \n",
      "5311                 0  \n",
      "2433                 0  \n",
      "6949                 0  \n",
      "13803                0  \n",
      "10583                0  \n",
      "769                  0  \n",
      "1685                 0  \n",
      "8322                 0  \n",
      "11111                0  \n",
      "11363                0  \n",
      "11636                0  \n",
      "14423                1  \n",
      "5578                 0  \n",
      "4426                 0  \n",
      "13526                1  \n",
      "466                  0  \n",
      "6265                 0  \n",
      "5734                 0  \n",
      "11284                0  \n",
      "11964                0  \n",
      "5191                 0  \n",
      "13418                0  \n",
      "5390                 0  \n",
      "860                  0  \n",
      "7270                 0  \n",
      "\n",
      "[10499 rows x 20 columns]\n"
     ]
    }
   ],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    " \n",
    "X_train, X_test, Y_train, Y_test = train_test_split(X, data_trnsf.left, test_size=0.3, random_state=42)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# create model\n",
    "model = Sequential()\n",
    "model.add(Dense(12, input_dim=20, activation='relu'))\n",
    "model.add(Dense(10, activation='relu'))\n",
    "model.add(Dense(1, activation='sigmoid'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Compile model\n",
    "model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 1/100\n",
      "10499/10499 [==============================] - 6s - loss: 0.6086 - acc: 0.7618     \n",
      "Epoch 2/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.5390 - acc: 0.7620     \n",
      "Epoch 3/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.5015 - acc: 0.7631     \n",
      "Epoch 4/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.4569 - acc: 0.7781     \n",
      "Epoch 5/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.3980 - acc: 0.8119     \n",
      "Epoch 6/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.3359 - acc: 0.8544     \n",
      "Epoch 7/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.3005 - acc: 0.8805     \n",
      "Epoch 8/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2818 - acc: 0.8874     \n",
      "Epoch 9/100\n",
      "10499/10499 [==============================] - 5s - loss: 0.2713 - acc: 0.8946     \n",
      "Epoch 10/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2639 - acc: 0.8979     \n",
      "Epoch 11/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2598 - acc: 0.8954     \n",
      "Epoch 12/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2568 - acc: 0.8983     \n",
      "Epoch 13/100\n",
      "10499/10499 [==============================] - 5s - loss: 0.2566 - acc: 0.8962     \n",
      "Epoch 14/100\n",
      "10499/10499 [==============================] - 5s - loss: 0.2570 - acc: 0.8991     \n",
      "Epoch 15/100\n",
      "10499/10499 [==============================] - 5s - loss: 0.2535 - acc: 0.9017     \n",
      "Epoch 16/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2538 - acc: 0.9008     \n",
      "Epoch 17/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2556 - acc: 0.9008     \n",
      "Epoch 18/100\n",
      "10499/10499 [==============================] - 5s - loss: 0.2554 - acc: 0.8980     \n",
      "Epoch 19/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2540 - acc: 0.9042     \n",
      "Epoch 20/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2512 - acc: 0.9032     \n",
      "Epoch 21/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2519 - acc: 0.9028     \n",
      "Epoch 22/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2529 - acc: 0.8999     \n",
      "Epoch 23/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2500 - acc: 0.9038     \n",
      "Epoch 24/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2513 - acc: 0.9014     \n",
      "Epoch 25/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2493 - acc: 0.9020     \n",
      "Epoch 26/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2500 - acc: 0.9038     \n",
      "Epoch 27/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2514 - acc: 0.9031     \n",
      "Epoch 28/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2500 - acc: 0.9045     \n",
      "Epoch 29/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2486 - acc: 0.9034     \n",
      "Epoch 30/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2520 - acc: 0.9031     \n",
      "Epoch 31/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2503 - acc: 0.9050     \n",
      "Epoch 32/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2471 - acc: 0.9075     \n",
      "Epoch 33/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2499 - acc: 0.9033     \n",
      "Epoch 34/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2469 - acc: 0.9060     \n",
      "Epoch 35/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2479 - acc: 0.9072     \n",
      "Epoch 36/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2508 - acc: 0.9025     \n",
      "Epoch 37/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2466 - acc: 0.9058     \n",
      "Epoch 38/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2454 - acc: 0.9048     \n",
      "Epoch 39/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2464 - acc: 0.9069     \n",
      "Epoch 40/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2451 - acc: 0.9068     \n",
      "Epoch 41/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2428 - acc: 0.9070     \n",
      "Epoch 42/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2427 - acc: 0.9078     \n",
      "Epoch 43/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2427 - acc: 0.9082     \n",
      "Epoch 44/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2412 - acc: 0.9088     \n",
      "Epoch 45/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2410 - acc: 0.9089     \n",
      "Epoch 46/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2402 - acc: 0.9100     \n",
      "Epoch 47/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2422 - acc: 0.9107     \n",
      "Epoch 48/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2388 - acc: 0.9114     \n",
      "Epoch 49/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2386 - acc: 0.9103     \n",
      "Epoch 50/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2356 - acc: 0.9113     \n",
      "Epoch 51/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2356 - acc: 0.9146     \n",
      "Epoch 52/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2373 - acc: 0.9112     \n",
      "Epoch 53/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2350 - acc: 0.9124     \n",
      "Epoch 54/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2378 - acc: 0.9119     \n",
      "Epoch 55/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2349 - acc: 0.9146     \n",
      "Epoch 56/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2350 - acc: 0.9163     \n",
      "Epoch 57/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2330 - acc: 0.9143     \n",
      "Epoch 58/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2383 - acc: 0.9127     \n",
      "Epoch 59/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2353 - acc: 0.9145     \n",
      "Epoch 60/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2377 - acc: 0.9133     \n",
      "Epoch 61/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2310 - acc: 0.9188     \n",
      "Epoch 62/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2353 - acc: 0.9150     \n",
      "Epoch 63/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2344 - acc: 0.9181     \n",
      "Epoch 64/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2331 - acc: 0.9180     \n",
      "Epoch 65/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2299 - acc: 0.9210     \n",
      "Epoch 66/100\n",
      "10499/10499 [==============================] - 3s - loss: 0.2333 - acc: 0.9199     \n",
      "Epoch 67/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2306 - acc: 0.9196     \n",
      "Epoch 68/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2334 - acc: 0.9199     \n",
      "Epoch 69/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2291 - acc: 0.9201     \n",
      "Epoch 70/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2305 - acc: 0.9208     \n",
      "Epoch 71/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2264 - acc: 0.9240     \n",
      "Epoch 72/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2307 - acc: 0.9219     \n",
      "Epoch 73/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2289 - acc: 0.9222     \n",
      "Epoch 74/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2292 - acc: 0.9221     \n",
      "Epoch 75/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2295 - acc: 0.9212     \n",
      "Epoch 76/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2269 - acc: 0.9236     \n",
      "Epoch 77/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2300 - acc: 0.9222     \n",
      "Epoch 78/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2268 - acc: 0.9238     \n",
      "Epoch 79/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2292 - acc: 0.9218     \n",
      "Epoch 80/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2251 - acc: 0.9247     \n",
      "Epoch 81/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2253 - acc: 0.9229     \n",
      "Epoch 82/100\n",
      "10499/10499 [==============================] - 3s - loss: 0.2213 - acc: 0.9269     \n",
      "Epoch 83/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2220 - acc: 0.9249     \n",
      "Epoch 84/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2216 - acc: 0.9262     \n",
      "Epoch 85/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2202 - acc: 0.9266     \n",
      "Epoch 86/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2201 - acc: 0.9283     \n",
      "Epoch 87/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2204 - acc: 0.9250     \n",
      "Epoch 88/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2187 - acc: 0.9273     \n",
      "Epoch 89/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2161 - acc: 0.9299     \n",
      "Epoch 90/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2146 - acc: 0.9276     \n",
      "Epoch 91/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2175 - acc: 0.9283     \n",
      "Epoch 92/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2178 - acc: 0.9254     \n",
      "Epoch 93/100\n",
      "10499/10499 [==============================] - 5s - loss: 0.2169 - acc: 0.9278     \n",
      "Epoch 94/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2178 - acc: 0.9271     \n",
      "Epoch 95/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2169 - acc: 0.9259     \n",
      "Epoch 96/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2146 - acc: 0.9291     \n",
      "Epoch 97/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2169 - acc: 0.9267     \n",
      "Epoch 98/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2162 - acc: 0.9280     \n",
      "Epoch 99/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2149 - acc: 0.9291     \n",
      "Epoch 100/100\n",
      "10499/10499 [==============================] - 4s - loss: 0.2128 - acc: 0.9304     \n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<keras.callbacks.History at 0x11c38bd30>"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Fit the model\n",
    "X_train = np.array(X_train)\n",
    "model.fit(X_train, Y_train, epochs=100, batch_size=10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10496/10499 [============================>.] - ETA: 0sacc: 0.9356%\n",
      "3904/4500 [=========================>....] - ETA: 0sacc: 0.9320%\n"
     ]
    }
   ],
   "source": [
    "# evaluate the model\n",
    "scores = model.evaluate(X_train, Y_train)\n",
    "print(\"%s: %.4f%%\" % (model.metrics_names[1], scores[1]))\n",
    "\n",
    "X_test = np.array(X_test)\n",
    " \n",
    "scores = model.evaluate(X_test, Y_test)\n",
    "print(\"%s: %.4f%%\" % (model.metrics_names[1], scores[1]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
